﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// 一堆子弹聚团，最后爆炸散开
/// </summary>
public class HeapBullet : MonoBehaviour
{

    public static readonly string TYPE = "heap_bullet";
    private List<NormalBullet> bullets;

    void OnTriggerEnter2D(Collider2D collider)
    {
        Entity entity = collider.GetComponent<Entity>();
        Entity bulletEntity = GetComponent<Entity>();

        if (Common.isCanAttack(bulletEntity, entity))
        {
            entity.hurt(bulletEntity.damage);
            BulletManager.pullBackBullet(gameObject, TYPE);
        }
    }

    /// <summary>
    /// 小炸弹四处飞
    /// </summary>
    public void explode() {

        foreach(NormalBullet bullet in bullets) {
            //算角度，改速度
        }
    }

    /// <summary>
    /// 没爆炸之前，小子弹处于暂停状态
    /// </summary>
    /// <param name="bullet"></param>
    private void pause(NormalBullet bullet) {
        bullet.GetComponent<PolygonCollider2D>().enabled = false; //碰撞关闭
        bullet.GetComponent<LineMover>().stop();
    }
}
